//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//

//------------------------------------------------------------------------------
//
//  Header: imm_api.h
//
//
//  IMM user mode function calls that simplify calls into the IMM
//  stream driver.
//  
//  
//------------------------------------------------------------------------------
#ifndef _IMM_API_H_
#define _IMM_API_H_
#include <xllp_defs.h>	// pkdebug
#if __cplusplus
extern "C" {
#endif
typedef enum _IMM_PRIORITY
{
	ALLOC_Q=0,
	ALLOC_L,
	ALLOC_M,
	ALLOC_H,
	ALLOC_L2CACHE,	//MH_L doesn't have L2CACHE,	ALLOC_L2CACHE is equal to ALLOC_H for MH_L
}IMM_PRIORITY;

typedef enum _IMM_FLAG
{
	ALLOC_DMA=1,
	ALLOC_NON_DMA,
}IMM_FLAG;

typedef enum _IMM_MEMTYPE
{
    
    MEMTYPE_ERROR=0,
    MEMTYPE_SRAM,
    MEMTYPE_DDR
    // Some other memory type may be added in future.
}IMM_MEMTYPE;

#define IMM_MALLOC_SRAM        0x01 /* force usage of sram */
#define IMM_MALLOC_HARDWARE    0x04 /* force contiguous, immovable physical pages */

typedef void* IMM_HANDLE;

HANDLE			IMM_CreateFile_Api(void);
XLLP_BOOL_T		IMM_DeviceIoControl_Api(HANDLE HandleDllApi,unsigned long v_start);
XLLP_BOOL_T		IMM_CloseHandle_Api(HANDLE HandleDllApi);


IMM_HANDLE			IMM_Register_API(void);
XLLP_BOOL_T		IMM_Unregister_API(IMM_HANDLE handle);


LPVOID  imm_malloc(IMM_HANDLE handle,size_t size, IMM_FLAG flags,IMM_PRIORITY imm_priority);
XLLP_INT32_T imm_free(IMM_HANDLE hd,void *address);
XLLP_INT32_T imm_free_immid(IMM_HANDLE hd);

XLLP_UINT32_T imm_get_physical(void *address);
XLLP_UINT32_T imm_get_freespace(XLLP_UINT32_T flags,IMM_HANDLE handle);

const _TCHAR *imm_error(IMM_HANDLE handle);

XLLP_UINT32_T imm_sram_page (_TCHAR *buffer, XLLP_UINT32_T size);
XLLP_UINT32_T imm_sram_vmap (_TCHAR *buffer, XLLP_UINT32_T size);
IMM_MEMTYPE imm_memory_type (XLLP_UINT32_T vaddr);
XLLP_BOOL_T imm_sram_range (XLLP_UINT32_T *start_addr, XLLP_UINT32_T* end_addr);
XLLP_UINT32_T total_sram_size (void);






//XLLP_UINT32_T total_sram_size(void);


//

#if __cplusplus
}
#endif


#endif // _IMM_API_H_


